

function ajax(option){
	    //url地址
    var url = option.url || null,
		//参数数据
		data = option.data || {}, 
		//发送类型
		method = option.method || 'get',
		//是否异步
		type = option.type || true,
		//是否跨域(jsonp)
		dataType = option.dataType || 'json',
		//是否上传文件
		file = option.file || false,
		//接收
		success = option.success || null; 


	var xhr;
	//创建XMLHttpRequest对象(兼容id低版本)
	xhr = window.XMLHttpRequest ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP"); 
	//发送请求
	if(method == 'get'){
		var xhr = new XMLHttpRequest();
		var arrData = [];
        for(var k in data){
		    arrData.push(k+'='+data[k]);
		}
		var item = arrData.join('&');
		url += '?'+item;
		xhr.open(method,url,type);
		xhr.send(null);
	}else if(method == 'post'){
		xhr.open(method,url,true);
	    //xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
		
		if(file){
			//xhr.setRequestHeader("multipart/form-data","application/x-www-form-urlencoded");
			xhr.send(data);
		}else{
			xhr.setRequestHeader('Content-type','application/x-www-form-urlencoded');
			var arrData = [];
			for(var k in data){
				arrData.push(k+'='+data[k]);
			}
			var item = arrData.join('&');
		    xhr.send(item);
		}
		
	}

	//接收
	xhr.onreadystatechange = function(){
		if(xhr.readyState == 4 && xhr.status == 200){
			success && success(xhr.responseText);
		}
	}

}